mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-17 16:20:48 +01:00
Code cleanup
This commit is contained in:
parent
4b4a1902ef
commit
992fd2c5cd
@ -128,7 +128,7 @@ int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
ln++;
|
||||
}
|
||||
|
||||
return (ln == 1) ? 1 : 0;
|
||||
return (ln < 9) ? ln : 0;
|
||||
}
|
||||
|
||||
bool MapFile::parseMapFile(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
@ -249,7 +249,7 @@ bool MapFile::computeTransformation(QList<CalibrationPoint> &points)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MapFile::load(QIODevice &file)
|
||||
MapFile::MapFile(QIODevice &file)
|
||||
{
|
||||
QList<CalibrationPoint> points;
|
||||
QString ct, datum;
|
||||
@ -257,13 +257,11 @@ bool MapFile::load(QIODevice &file)
|
||||
const GCS *gcs;
|
||||
|
||||
if (!parseMapFile(file, points, ct, setup, datum))
|
||||
return false;
|
||||
return;
|
||||
if (!(gcs = createGCS(datum)))
|
||||
return false;
|
||||
return;
|
||||
if (!createProjection(gcs, ct, setup, points))
|
||||
return false;
|
||||
return;
|
||||
if (!computeTransformation(points))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
_image = QString();
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ class QIODevice;
|
||||
class MapFile
|
||||
{
|
||||
public:
|
||||
bool load(QIODevice &file);
|
||||
MapFile(QIODevice &file);
|
||||
|
||||
bool isValid() const {return !_image.isNull() && _projection.isValid();}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
||||
const Projection &projection() const {return _projection;}
|
||||
|
@ -113,9 +113,9 @@ OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
||||
_errorString = "Map file not found";
|
||||
return;
|
||||
}
|
||||
QBuffer mapFile(&ba);
|
||||
MapFile mf;
|
||||
if (!mf.load(mapFile)) {
|
||||
QBuffer buffer(&ba);
|
||||
MapFile mf(buffer);
|
||||
if (!mf.isValid()) {
|
||||
_errorString = mf.errorString();
|
||||
return;
|
||||
} else {
|
||||
@ -126,9 +126,9 @@ OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
||||
_transform = mf.transform();
|
||||
}
|
||||
} else if (suffix == "map") {
|
||||
MapFile mf;
|
||||
QFile mapFile(fileName);
|
||||
if (!mf.load(mapFile)) {
|
||||
QFile file(fileName);
|
||||
MapFile mf(file);
|
||||
if (!mf.isValid()) {
|
||||
_errorString = mf.errorString();
|
||||
return;
|
||||
} else {
|
||||
@ -177,21 +177,19 @@ OfflineMap::OfflineMap(const QString &fileName, Tar &tar, QObject *parent)
|
||||
: Map(parent), _img(0), _tar(0), _ozf(0), _zoom(0), _valid(false)
|
||||
{
|
||||
QFileInfo fi(fileName);
|
||||
MapFile mf;
|
||||
|
||||
|
||||
QFileInfo map(fi.absolutePath());
|
||||
QFileInfo layer(map.absolutePath());
|
||||
QString mapFile = layer.fileName() + "/" + map.fileName() + "/"
|
||||
+ fi.fileName();
|
||||
|
||||
QByteArray ba = tar.file(mapFile);
|
||||
if (ba.isNull()) {
|
||||
_errorString = "Map file not found";
|
||||
return;
|
||||
}
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
if (!mf.load(buffer)) {
|
||||
MapFile mf(buffer);
|
||||
if (!mf.isValid()) {
|
||||
_errorString = mf.errorString();
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user