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