Skip to content

Commit

Permalink
make qstarz format dynamic (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 authored Nov 9, 2023
1 parent 9500fdf commit 8610073
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
26 changes: 7 additions & 19 deletions qstarz_bl_1000.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*
stream >> unused2;

if (stream.status() != QDataStream::Ok) {
fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Perhaps this isn't a Qstarz BL-1000 file");
fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Perhaps this isn't a Qstarz BL-1000 file");
}

BL1000_POINT_TYPE type;
Expand Down Expand Up @@ -171,7 +171,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*
default:
type = BL1000_POINT_TYPE_UNKNOWN;

fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for RCR (record reason): " << rcr);
fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for RCR (record reason): " << rcr);

break;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*
fix = fix_unknown;

if (type != BL1000_POINT_TYPE_UNKNOWN) {
fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for fix quality: " << fixQuality);
fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for fix quality: " << fixQuality);
}

break;
Expand All @@ -219,11 +219,11 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*
// qDebug(waypoint)

if ((waypoint->latitude < -90) || (waypoint->latitude > 90)) {
fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for latitude: " << waypoint->latitude);
fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for latitude: " << waypoint->latitude);
}

if ((waypoint->longitude < -180) || (waypoint->longitude > 180)) {
fatal(FatalMsg() << MYNAME << ": File format error on " << read_fname << ". Unexpected value for longitude: " << waypoint->longitude);
fatal(FatalMsg() << MYNAME << ": File format error on " << fname << ". Unexpected value for longitude: " << waypoint->longitude);
}

waypoint->altitude = altitude;
Expand Down Expand Up @@ -268,24 +268,12 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*
* entry points called by gpsbabel main process *
***************************************************************************/

void
QstarzBL1000Format::rd_init(const QString& fname)
{
read_fname = fname;
}

void
QstarzBL1000Format::rd_deinit()
{
read_fname.clear();
}

void
QstarzBL1000Format::read()
{
QFile file(read_fname);
QFile file(fname);
if (!file.open(QIODevice::ReadOnly)) {
fatal(FatalMsg() << MYNAME << ": Error opening file " << read_fname);
fatal(FatalMsg() << MYNAME << ": Error opening file " << fname);
}

QDataStream stream(&file);
Expand Down
10 changes: 3 additions & 7 deletions qstarz_bl_1000.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct qstarz_bl_1000_fsdata : FormatSpecificData {
class QstarzBL1000Format : public Format
{
public:
using Format::Format;

ff_type get_type() const override
{
return ff_type_file;
Expand All @@ -69,15 +71,9 @@ class QstarzBL1000Format : public Format
};
}

void rd_init(const QString& fname) override;
void rd_init(const QString& fname) override {}
void read() override;
void rd_deinit() override;
void qstarz_bl_1000_read(QDataStream& stream);
void qstarz_bl_1000_read_record(QDataStream& stream, route_head* track_route);

private:
QString read_fname;
};


#endif
4 changes: 2 additions & 2 deletions vecs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ struct Vecs::Impl {
GarminFitFormat format_fit_fmt;
GeoJsonFormat geojson_fmt;
GlobalsatSportFormat globalsat_sport_fmt;
QstarzBL1000Format qstarz_bl_1000_fmt;
#endif // MAXIMAL_ENABLED

const QVector<vecs_t> vec_list {
Expand Down Expand Up @@ -488,11 +487,12 @@ struct Vecs::Impl {
nullptr,
},
{
&qstarz_bl_1000_fmt,
nullptr,
"qstarz_bl-1000",
"Qstarz BL-1000",
nullptr,
nullptr,
&fmtfactory<QstarzBL1000Format>
},
{
nullptr,
Expand Down

0 comments on commit 8610073

Please sign in to comment.